<template>
  <div id="iExit">
    <!-- <div class="exit unSelect" @click="exit()">登出</div> -->
    <div class="exit">
      <el-dropdown trigger="click" @command="handleCommand">
        <span class="el-dropdown-link">
          <div class="exit-icon">
            <img src="../assets/images/cr18g/logo.jpg" alt="" />
          </div>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item icon="el-icon-user-solid" command="User">个人信息</el-dropdown-item>
          <el-dropdown-item icon="el-icon-switch-button" command="exit">登出</el-dropdown-item>
          <!-- <el-dropdown-item icon="el-icon-info" divided disabled>v{{ version }}</el-dropdown-item> -->
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
import setting from '../setting'
import { logOut } from '../utils/auth'
import { removeMenuDefaultPath } from '../utils/local'
export default {
  name: 'iExit',
  data() {
    return {
      version: '1.0.0'
    }
  },
  methods: {
    handleCommand(command) {
      if (command === 'exit') {
        this.exit()
      } else {
        this.$router.push({name: command.toString()})
      }
    },
    exit() {
      this.$store.commit('clearLocalData')
      logOut()
      removeMenuDefaultPath()
      this.$message.info(`已登出，请重新登录`)
      this.$router.push({name: setting.publicIndexPage})
    }
  }
}
</script>

<style lang="scss">
#iExit {
  .exit {
    transition: all 0.2s ease-out;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #006886;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;

    &:hover {
      box-shadow: 0 0 5px #006886;
    }

    .el-dropdown-link {
      overflow: hidden !important;
      display: flex;
      justify-content: center;
      align-items: center;

      .exit-icon {
        width: 100%;
        height: 100%;
        border-radius: 5px;
        overflow: hidden;
        display: flex;
        justify-content: center;
        align-items: center;

        img {
          width: 100%;
          height: 100%;
        }
      }
    }
  }
}
</style>
